<?php
/**
 * Created by PhpStorm.
 * User: 聪
 * Date: 2019/7/15
 * Time: 18:01
 */

namespace app\front\model;


use app\BaseModel;

class Contract extends BaseModel
{
    public $allowQuery = 'id,signing_subject,channel_company,create_time';
    public $autoWriteTimestamp = true;
    public  $onlineState = [
        1 => '未创建',
        2 => '已创建',
        3 => '待审核',
        4 => '审核通过',
        5 => '审核不通过',
    ];


    public  $offlineState = [
        1 => '未寄出',
        2 => '已寄出',
        3 => '未寄回',
        4 => '已寄回',
    ];

    public function User()
    {
        return $this->hasOne('User', 'id', 'uid')->field('id,nickname')->bind('nickname');
    }

    public function getCreateTimeAttr($val)

    {
        return date('y/m/d - H时i分', $val);
    }

//    public function getTimeOnlineAttr($val)
//    {
//        return date('Y-m-d H:i', $val);
//    }

    public function getOnlineStateAttr($val)
    {
        return $this->onlineState[$val];
    }

    public function getOfflineStateAttr($val)
    {
        return $this->offlineState[$val];
    }
}